#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File    :   university.py    
@Contact :   291622538@qq.com

@Modify Time      @Author    @Version    @Description
------------      -------    --------    -----------
2021/4/13 15:11   fan        1.0         None
"""
import csv

if __name__ == '__main__':

    result = []

    with open('university_list.csv', 'r', encoding='utf-8') as f:

        for num, line in enumerate(csv.reader(f)):
            if num == 0:
                line.append("domainName")

                result.append(line)
                continue

            # if num == 2:
            #     break

            url = line[3]
            domain = url.split("//")[-1].split("/")[0]

            if "www." in domain:
                domain = domain.replace("www.", "")
            line.append(domain)
            result.append(line)
        # print(result)

    with open('university_list_new.csv', 'w', encoding='utf-8', newline='') as f:
        writer = csv.writer(f)
        writer.writerows(result)
